package inge_soft.gestoriusNuevo.persistence.DAO.implementation;

import inge_soft.gestoriusNuevo.persistence.DAO.Exceptions.Abstraction.GestoriusException;
import inge_soft.gestoriusNuevo.persistence.DAO.abstraction.IDocumentoDAO;
import inge_soft.gestoriusNuevo.persistence.entity.implementation.Documento;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Repository("documentoDAO")
public class DocumentoDAO implements IDocumentoDAO {

	@PersistenceContext
	private EntityManager entityManager;
	
	//static final Logger logger = Logger.getLogger(DocumentoDAO.class);
	
	@Transactional(propagation = Propagation.MANDATORY)
	public void crear(Documento documento) throws GestoriusException {
		entityManager.persist(documento);
	}

	@Transactional(propagation = Propagation.MANDATORY)
	public void modificar(Documento documento) throws GestoriusException {
		entityManager.merge(documento);
	}

	@Transactional(propagation = Propagation.MANDATORY)
	public void eliminar(Documento documento) throws GestoriusException {
		//entityManager.
	}

}
